<?php

namespace app\common;

use GuzzleHttp\Client;


class Sms
{
	
	
	/**
	 * 校验验证码
	 * @param int $mobile 手机号
	 * @param int $code 验证码
	 * @param string $event 事件 登录=login,注册=register,换绑手机号=changemobile,更改密码=changepwd,重置密码=resetpwd
	 * @return  boolean
	 */
	public static function check($mobile, $code, $event = 'default')
	{
		
		$client = new Client();
		$ret = $client->post(env('ADMIN_HOST').'/api/Sms/check',[
			'json'=>[
				'mobile'=>$mobile,
				'event'=>$event,
				'captcha'=>$code,
			]
		]);
		$ret = $ret->getBody()->getContents();
		$ret = json_decode($ret);
		if ($ret->code != 1){
			return false;
		}
		return true;
	}
	
}